package com.taobao.analyse.map;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;

import com.taobao.analyse.constants.SplitConstants;

/**
 * 用于计算一级类目下调整价格的频率
 * 
 * @author Livis
 * 
 */
public class CategoryPriceChangeRateMapper extends MapReduceBase implements
		Mapper<Writable, Text, LongWritable, Text> {

	@Override
	public void map(Writable key, Text value,
			OutputCollector<LongWritable, Text> output, Reporter reporter)
			throws IOException {
		String line = value.toString();

		String[] datas = line.split(SplitConstants.SPLIT_OUTPUT);

		if (datas.length < 2) {
			return;
		}

		output.collect(new LongWritable(Long.parseLong(datas[0])), new Text(
				datas[1]));

	}

}
